const { DataTypes } = require('sequelize');
const { sequelize } = require('../init'); // 导入数据库连接配置
// 工单表
const WorkOrder = sequelize.define('WorkOrder', {
    WorkOrderID: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },
    WorkOrderName: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    WorkOrderDescription: {
        type: DataTypes.TEXT,
        allowNull: true,
    },
    CreatedDate: {
        type: DataTypes.DATE,
        allowNull: false,
    },
    DueDate: {
        type: DataTypes.DATE,
        allowNull: false,
    },
    Status: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    AssignedUserID: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    CreatedUserID: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    Income: {
        type: DataTypes.FLOAT,
        allowNull: false,
    }
}, {
    tableName: 'workorder', // 显式指定表名为 "workorder"
    timestamps: false, // 如果表中不包含 createdAt 和 updatedAt 字段，请将此选项设置为 false
    collate: 'utf8mb4_bin' // 设置字符集规则
});
// 帮我打印一下数据库连接情况
WorkOrder.sync({ force: false }).then(() =>
{
    console.log('工单表准备');
});
module.exports = { WorkOrder };
